package com.fl.mybatisgenerator.service.impl;

import com.fl.mybatisgenerator.entity.ThreadData;
import com.fl.mybatisgenerator.service.AsyncService;
import com.fl.mybatisgenerator.mapper.ThreadDataMapper;
import com.fl.mybatisgenerator.service.ThreadDataService;
import com.mysql.cj.log.Log;
import lombok.extern.slf4j.Slf4j;
import org.apache.ibatis.logging.LogFactory;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.scheduling.annotation.Async;
import org.springframework.stereotype.Component;
import org.springframework.stereotype.Service;

import javax.annotation.Resource;
import java.util.List;
import java.util.logging.Logger;

@Service("AsyncService")
@Slf4j
@Component
public class AsymcServiceimpl implements AsyncService,Runnable {
    @Resource
    private ThreadDataMapper mapper;
    private ThreadData threadData;

    @Async
    @Override
    public void Svein(ThreadData data) {
        log.info("插入对象:{}", data.toString());
//        service.save(data);
        mapper.insert(data);
        this.threadData = data;
    }

    @Override
    public void run() {
        log.info("插入对象:{}", threadData.toString());
        mapper.insert(threadData);
    }
}
